package pr;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class LoadImage {

	public static void main(String[] args) throws IOException {
		String binaryImageData = "resource/BinaryImageData.txt";
		String grayscaleImageData = "resource/GrayscaleImageData.txt";
		int binaryArray[][] = null;
		int greyArray[][];
		BufferedReader binaryBr = null;
		BufferedReader greyBr = null;
		String line;
		int number;
		int rowIndex;
		int columnIndex;
		/*
		 * try {
		 * 
		 * try { binaryBr = new BufferedReader(new InputStreamReader( new
		 * FileInputStream(binaryImageData)));
		 * 
		 * rowIndex=0; while ((line = binaryBr.readLine()) != null) { //
		 * System.out.println(line);
		 * 
		 * for (int index = 0; index < line.length(); index++) { char aChar =
		 * line.charAt(index); System.out.println(aChar); //
		 * binaryArray[rowIndex][index] = aChar; } rowIndex++; }
		 * 
		 * } catch (FileNotFoundException e) {
		 * 
		 * e.printStackTrace(); } System.out.println("\n\n\n\n\n"); try { greyBr
		 * = new BufferedReader(new InputStreamReader( new
		 * FileInputStream(grayscaleImageData))); while ((line =
		 * greyBr.readLine()) != null) { System.out.println(line); } } catch
		 * (FileNotFoundException e) {
		 * 
		 * e.printStackTrace(); }
		 * 
		 * } finally { binaryBr.close(); greyBr.close();
		 * 
		 * }
		 */
		
		System.out.println("asdf");
		
		int row = 26;
		int col = 138;
		/*try {
			Scanner scanner = new Scanner(new File(binaryImageData));
			while (scanner.hasNextLine()) {
				++row;
				Scanner colScanner = new Scanner(scanner.nextLine());
				while (colScanner.hasNextInt()) {
					++col;
				}
				colScanner.close();
			}
			scanner.close();
		} catch (FileNotFoundException fnf) {
			fnf.printStackTrace();
		}*/
		
		int[][] a = new int[26][138];
		
		System.out.println(row + "\t\tcol:"+ col);
		
		try {
			Scanner input = new Scanner(new File(binaryImageData));
			for (int i = 0; i < row; i++) {
				for (int j = 0; j < col; j++) {
					if (input.hasNextInt()) {
						a[i][j] = input.nextInt();
					}
				}
			}
			input.close();
		} catch (FileNotFoundException fnf) {
			fnf.printStackTrace();
		}
		
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) 
				System.out.print(a[i][j]);
			System.out.println();
		}
	}
}
